<?php
/*
	首页
*/

defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$_SESSION['uid']=$_SESSION['uid']?:0;
if($_RQ['op']=='main'){
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','mobile','avatar','nickname'));
	$passdays=$return['pluginset']['passdays']?$return['pluginset']['passdays']-1:6;
	$member['credit1passtime']=date('Y年m月d日',time()+$passdays*24*3600);
	$member['issign']=$_SESSION['issign'];
	$credit1=$member['issign']?$return['pluginset']['jifen']+$return['pluginset']['day1']:$return['pluginset']['jifen'];
	$member['credit1']=$_SESSION['uid']?$member['credit1']:$credit1;
	if(!$_SESSION['uid']){
		$_SESSION['nowcredit1']=$member['credit1'];
	}
	$member['credit1']=$_SESSION['uid']?$member['credit1']:$_SESSION['nowcredit1'];
	$return['member']=$member;
	$return['list']=array();
	$p_group=pdo_getall('jy_creditshop_category',array('uniacid'=>$_SESSION['uniacid'],'enabled'=>1,'isrecommand'=>1),'','displayorder asc');
	$return['allprice']=pdo_getsum('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'deleted'=>0,'status'=>0),'price');
	$end_time=strtotime(date('Y-m-d',strtotime('+1 day')));
	$end_time=$end_time-TIMESTAMP;
	$return['rest_time']=model('jy_weishop/model')->date($end_time);
	$return['dingxieyi']=$this->plugin_setting('xieyi');
	$return['login']=$_SESSION['uid']?1:2;
	$return['p_group']=$p_group;
	$return['params']['cateid']=$p_group[0]['id'];
	set_html('title',$return['pluginset']['title']?'首页-'.$return['pluginset']['title']:'首页-积分优选');
	$return['sharedata']=array(
		'title'=>$return['pluginset']['share_title']?$return['pluginset']['share_title']:'首页-积分优选',
		'desc'=>$return['pluginset']['share_desc']?$return['pluginset']['share_desc']:'积分优选单商户版，主流经典积分优选，拼着买，更便宜！',
		'link'=>custom_url('jy_jifenyou/index//fromuser='.$_SESSION['uid'],true),
		'imgUrl'=>$return['pluginset']['share_image']?tomedia($return['pluginset']['share_image']):tomedia($return['pluginset']['icon'])
	);
	exi($return);
}
if($_RQ['op']=='sign'){
	//点击签到
	$this->model()->signday(true);
	//返回成功状态
	exi('签到成功！');
}
?>